package cn.flightcloud.auth.web;

import java.security.Principal;
import java.util.HashMap;
import java.util.Map;

import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class UserController {

	@RequestMapping(value="user")
	public Map<String,Object> user(Principal principal) {
		Map<String,Object> map = new HashMap<>();
		UsernamePasswordAuthenticationToken token = (UsernamePasswordAuthenticationToken)principal;
		map.put("username", token.getName());
		return map;
	}

}
